package day17;

import java.time.LocalTime;
import java.util.Scanner;

public class Timer implements Runnable{
    public void run() {
        Scanner sc=new Scanner(System.in);
        System.out.print("请输入时间(秒):");
        int time= sc.nextInt();
        LocalTime lt=LocalTime.of(0,0,0);
        System.out.println("计时开始！");
        for (int i=1;i<=time;i++){
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            lt=lt.plusSeconds(1);
            System.out.println("已经过了:"+lt+"秒");
            if (i==time){
                System.out.println("时间到，计时结束！");
            }
        }
    }
    public static void main(String[] args) {
        Timer timer=new Timer();
        timer.run();
    }
}

